import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus' // 引入ElementPlus
import zhCn from 'element-plus/es/locale/lang/zh-cn' // 引入ElementPlus中文支持
import 'element-plus/dist/index.css'  //引入element-plus样式
import * as ElementPlusIconsVue from '@element-plus/icons-vue'  // 引入Elementplus所有图标
import 'virtual:svg-icons-register' // svg插件配置
import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersistedState from 'pinia-plugin-persistedstate' // pinia数据持久化插件
import '@/assets/styles/index.scss' // 样式重置, 防止原生样式影响显示
import '@/common/style.scss' // 导入公共样式
import hasPermi from './directive/permission/hasPermi'

const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedState)

app.use(pinia)
    .use(router)
    // 安装ElementPlus插件
    .use(ElementPlus, { locale: zhCn })
    // 使用权限判断指令
    .directive('hasPermi', hasPermi)

// 将Elementplus图标进行全局注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.mount('#app')
